package com.hup.joystick.view.main;

import com.hup.utils.commons.start.*;
import com.hup.utils.swing.frame.SingletonWindowHelper;

/**
 * @author hugan
 * @date 2020/10/28
 */
public class AppTray extends BaseAppTray {

    public AppTray() {
        super(SpringContext.getBean(AppIcon.class).getImage(), StartupInfo.getApplicationChName());
        setPopupMenu(new SimpleMenu().addExit(), null);
        setTrayListener(new TrayActionListener() {
            @Override
            public void onClickTray() {
                MainWindow window = SingletonWindowHelper.getWindow(MainWindow.class);
                window.switchVisible(true);
            }

            @Override
            public void onExit(BaseAppTray appTray) {
                SingletonWindowHelper.getWindow(MainWindow.class).dispose();
                SpringContext.getBean(SimpleExitHandler.class).doExit();
            }
        });
    }

}
